import type {
  ConsultOrderParams,
  GetPatientConsultOrderPreData,
  GetPatientConsultOrderPreParams,
  ConsultPayParams,
  GetPatientConsultOrderDetailData,
} from '@/types/consult'
import type { DepartmentItem } from '@/types/consult'
import { http } from '@/utils/http'
import type { Image } from '@uni-helper/uni-app-types'

/** 获取科室列表--请求API */
export const getAllDepartmentApi = () => {
  return http.get<DepartmentItem[]>('/dep/all')
}

/** 保存/修改问诊订单--请求API */
export const consultOrderApi = (data: ConsultOrderParams) => {
  return http.post<{ id: string }>('/patient/consult/order', data)
}

/** 支付页面-计算就诊信息和抵扣信息--请求API */
export const getPatientConsultOrderPreApi = (params: GetPatientConsultOrderPreParams) => {
  return http.get<GetPatientConsultOrderPreData>('/patient/consult/order/pre', { params })
}

/** 三方支付（暂时只支持支付宝支付）--请求API */
export const postPatientConsultPayApi = (data: ConsultPayParams) => {
  return http.post<{ payUrl: string }>('/patient/consult/pay', data)
}

/**
 * 问诊订单详情
 */
export const orderDetailApi = (orderId: string) => {
  return http.get<GetPatientConsultOrderDetailData>('/patient/consult/order/detail', {
    params: { orderId },
  })
}

/**
 * 上传病情描述图片
 * @param filePath 图片filePath
 * @returns
 */
export const uploadImageApi = (filePath: string) => {
  return http.upload<Image>('/upload', {
    name: 'file',
    filePath,
  })
}
